<template>
  <div class="init-page-overlay" v-if="active === 1">
    <div class="box">
      <NuxtImg
        class="img"
        src="/images/init-page/17552646839629fqwa.jpg"
        @click="toActivity"
      />
      <div class="icon-box" @click="close">
        <NuxtImg class="icon" src="/images/layout/icon-close2.png" />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
defineProps(["active"]);
const emits = defineEmits(["close"]);

function toActivity() {
  showNotify({
    message: "新开弹窗-前往活动，并关闭",
    type: "success",
  });
  close();
}

function close() {
  emits("close");
}
</script>

<style scoped lang="scss">
// 合并动画关键帧，使用更语义化的名称
@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes slideInScale {
  0% {
    transform: translateY(-60%) scale(0.5);
  }
  100% {
    transform: translateY(-60%) scale(1);
  }
}

// 合并重复的定位和动画属性
.init-page-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  z-index: 9999;
  opacity: 0;
  animation: fadeIn 0.4s forwards;
}

.box {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 8.47rem;
  transform: translateY(-60%);
  display: flex;
  justify-content: center;
  animation: slideInScale 0.4s forwards;
}

.img {
  height: 100%;
}

.icon-box {
  position: absolute;
  bottom: -1.8rem;
  padding: 0.4rem;
  cursor: pointer;
}

.icon {
  width: 0.4rem;
}
</style>
